<template>
  <div style="padding: 10px;">
    <el-card>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item :label="$t('用户id')">
          <el-input size="small" v-model="formInline.userId"></el-input>
        </el-form-item>
        <el-form-item :label="$t('流转方账户')">
          <el-input size="small" v-model="formInline.userName"></el-input>
        </el-form-item>
        <el-form-item :label="$t('状态')">
          <el-select size="small" v-model="formInline.status">
            <el-option :label="$t('无效')" :value="0"></el-option>
            <el-option :label="$t('有效')" :value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('渠道名称')">
          <el-select size="small" v-model="formInline.channelSource">
            <el-option label="流转" :value="1"></el-option>
            <el-option label="分享" :value="2"></el-option>
            <el-option label="每日解锁" :value="3"></el-option>
            <el-option label="团队分红" :value="4"></el-option>
            <el-option label="充值" :value="5"></el-option>
            <el-option label="转账" :value="6"></el-option>
            <el-option label="购买流量包" :value="7"></el-option>
            <el-option label="CFP兑换USDT" :value="8"></el-option>
            <el-option label="USDT兑换CFP" :value="9"></el-option>
            <el-option label="流量包销毁" :value="10"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('创建时间')">
          <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-model="formInline.createTime" size="small" type="datetime"
            :placeholder="$t('选择日期时间')">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" @click="onSubmit">{{ $t('query') }}</el-button>
          <el-button size="small" type="warning" @click="reset">{{ $t('重置') }}</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-card style="margin-top: 10px;">
      <el-table v-loading="loading" :data="tableData" style="width: 100%">
        <el-table-column prop="userId" :label="$t('用户id')"> </el-table-column>
        <el-table-column prop="userName" :label="$t('流转方账户')">
        </el-table-column>
        <el-table-column prop="incomeAmount" :label="$t('金额')">
          <template #default="{ row }">
            {{ type[row.channelSource].value }}{{ row.incomeAmount }}
          </template>
        </el-table-column>
        <el-table-column prop="accountBalance" :label="$t('账户结余')">
        </el-table-column>
        <el-table-column prop="channelName" :label="$t('渠道名称')">
          <template #default="{ row }">
            {{ $t(`${type[row.channelSource].label}`) }}
          </template>
        </el-table-column>
        <el-table-column prop="transferredUserName" label="被流转方账户">
        </el-table-column>
        <el-table-column prop="status" :label="$t('状态')">
          <template #default="{ row }">
            {{ row.status ? $t('有效') : $t('无效') }}
          </template>
        </el-table-column>
        <!-- <el-table-column prop="incomeAmount" :label="$t('收入金额')">
        </el-table-column>
        <el-table-column prop="transferExpenses" :label="$t('转账支出')">
        </el-table-column>
        <el-table-column prop="flowPackageExpenditure" :label="$t('购买流量包支出')">
        </el-table-column>
        <el-table-column prop="statusName" :label="$t('状态')">
          <template #default="{ row }">
            {{ $t(`${row.statusName}`) }}
          </template>
        </el-table-column>
        <el-table-column prop="channelName" :label="$t('渠道名称')">
          <template #default="{ row }">
            {{ $t(`${row.channelName}`) }}
          </template>
        </el-table-column> -->
        <el-table-column prop="createTime" :label="$t('创建时间')">
        </el-table-column>
      </el-table>
      <el-pagination style="float: right;margin: 5px 0;" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" :page-size="page.pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </el-card>
  </div>
</template>
<script>
import { getearningsDetailApi } from "@/api/appuser/earningsDetail";
export default {
  data() {
    return {
      tableData: [],
      loading: false,
      total: 0,
      page: {
        pageNum: 1,
        pageSize: 10,
      },
      formInline: {
        userId: null,
        userName: null,
        statusName: null,
        createTime: null,
        channelSource: null,
      },
      type: {
        //渠道来源（1、流转，2、分享、3、每日解锁，4、团队分红，5、充值） 7购买流量包 6 转账 8 CFP兑换USDT 9 USDT兑换CFP 10 流量包销毁
        1: {
          value: "+",
          label: "流转",
        },
        2: {
          value: "+",
          label: "分享",
        },
        3: {
          value: "+",
          label: "每日解锁",
        },
        4: {
          value: "+",
          label: "团队分红",
        },
        5: {
          value: "+",
          label: "充值",
        },
        7: {
          value: "-",
          label: "购买流量包",
        },
        6: {
          value: "-",
          label: "转账",
        },
        8: {
          value: "-",
          label: "CFP兑换USDT",
        },
        9: {
          value: "+",
          label: "USDT兑换CFP",
        },
        10: {
          value: "+",
          label: "流量包销毁",
        },
      },
    };
  },
  created() {
    this.getearningsDetail();
  },
  methods: {
    async getearningsDetail() {
      this.loading = true;
      const res = await getearningsDetailApi({
        ...this.page,
        ...this.formInline,
        // userName: "333@qq.com",
      });
      console.log(res);
      this.tableData = res.list;
      this.total = res.total;
      this.loading = false;
    },
    handleSizeChange(val) {
      this.page.pageSize = val;
      this.getearningsDetail();
    },
    handleCurrentChange(val) {
      this.page.pageNum = val;
      this.getearningsDetail();
    },
    onSubmit() {
      console.log(this.formInline);
      this.page = {
        pageNum: 1,
        pageSize: 10,
      };
      this.getearningsDetail();
    },
    reset() {
      this.page = {
        pageNum: 1,
        pageSize: 10,
      };
      this.formInline = {
        userId: null,
        userName: null,
        statusName: null,
        createTime: null,
      };
      this.getearningsDetail();
    },
  },
};
</script>
<style lang='' scoped>
</style>